<?php
// +----------------------------------------------------------------------
// | 前台日志
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: PostsAction.class.php 122 2011-05-18 09:00:37Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class PostsAction extends BaseAction {
	
	protected function show($map) {
	
		$page = D ('Posts');
	
		if ($vo = $page->where($map)->relation(true)->find()) {
		    /* 获取评论*/
		    $c = A('Public');
			$c->getCommentByPostsId($vo['posts_id']);
			$this->assign('vo',$vo);
			if ($vo['posts_type'] == '2') {
				$this->display('Index:page');
			} else {
				$this->display('Index:show');
			}
		} else {
			$this->error404();
		}
	}
  
	//空操作
	protected function error404() {
		$this->error('Error 404 - Not Found');
	}
	
	public function _empty() {
		
		//过滤
		$map = array();
		$map['posts_status']  =	 1;      //状态正常
		$map['posts_draft']   =  1;      //日志或页面必须是已发布
		
		if(is_numeric(ACTION_NAME)) {
			$map['posts_id'] = ACTION_NAME;
		} else {
			$map['posts_url'] = ACTION_NAME;
		}
		
		$this->show($map);
	}
	
}

?>